package com.daxue.design.strategy;

/**
 * @author daxue0929
 * @date 2023/2/11
 */

public class Context {

    private Strategy strategy;

    public Context(Strategy strategy) {
        this.strategy = strategy;
    }

    //提供set方法，支持运行时改变算法
    public void setStrategy(Strategy strategy) {
        this.strategy = strategy;
    }

    //根据具体的策略对象，调用其算法的方法
    public void contextStrategy(){
        strategy.strategy();
    }
}
